import { AdManager } from "../ads/AdManager";
import { UIManager } from "../manager/UIManager";
import GameUI from "./GameUI";

const { ccclass, property } = cc._decorator;

@ccclass
export default class MagnetUI extends cc.Component {

    private isClick: boolean = false;

    protected async onLoad() { }

    private onBtnsClicked(event: cc.Event, data: cc.Event.EventCustom) {
        const name = event.target.name;
        switch (name) {
            case "btnGet":         // 获取
                {
                    if (this.isClick) { return; }
                    this.isClick = true;
                    AdManager.showVideoAd(() => {
                        this.isClick = false;
                        GameUI.instance.magent(() => {
                            UIManager.ins.close();
                        });
                    }, () => {
                        this.isClick = false;
                    });
                }
                break;
            case "btnClose":     // 关闭
                {
                    UIManager.ins.close();
                }
                break;
        }
        // console.log("onReviveClicked()===>按钮:", name);
    }
}